package com.taxsystem.fangzicheng.governmentservice;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.main.taxsystem.ListAndSearchActivity;
import com.main.taxsystem.R;
import com.taxsystem.fangzicheng.taxpolicy.TaxPolicyActivity;

import android.os.Bundle;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.SimpleAdapter;
import android.widget.AdapterView.OnItemClickListener;


public class GovernmentServiceAcitvity extends Activity {
	private static final int GRID_ITEM_ICON[] = new int[] {R.drawable.temp_logo,R.drawable.temp_logo,R.drawable.temp_logo,R.drawable.temp_logo};
	private static final String GRID_ITEM_TITLE[] = new String[]{
		"公告通知",
		"最新动态",
		"机构设置",
		"欠税公告"
	};
	 private GridView gridView;
	 
	 Intent intent;
	 int item = 0;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.grid_view_layout_cwz);
			
			ActionBar bar = getActionBar();
	        bar.setHomeButtonEnabled(true);
	        bar.setIcon(R.drawable.actionbar_icon);
	        bar.setDisplayHomeAsUpEnabled(true);
	        bar.setBackgroundDrawable(new ColorDrawable(0xff34a4f7));
	        
			gridView = (GridView) findViewById(R.id.gridView);
	       List<Map<String, Object>> data = new ArrayList<Map<String,Object>>();
	       for(int i=0;i<GRID_ITEM_ICON.length;i++){
	       Map<String,Object> map = new HashMap<String, Object>();
	          map.put("icon",GRID_ITEM_ICON[i]);
	          map.put("title",GRID_ITEM_TITLE[i]);
	          data.add(map);
	       }
	      SimpleAdapter simpleAdapter = new SimpleAdapter(this, data,R.layout.grid_item, 
	    		  new String[]{"title","icon"}, new int[]{R.id.text_item,R.id.image_item});
	      gridView.setAdapter(simpleAdapter);
	      gridView.setOnItemClickListener(new OnItemClickListener() {
				@Override
				public void onItemClick(AdapterView<?> parent, View v,
						int position, long id) {
					Intent intent = new Intent(GovernmentServiceAcitvity.this,
							ListAndSearchActivity.class);
					intent.putExtra("title", GRID_ITEM_TITLE[position]);
					startActivity(intent);
				}
			});
		}
	}
